﻿<Page
    x:Name="pageRoot"
    x:Class="SmartPatientCentre.Pages.Dashboard"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SmartPatientCentre.Pages"
    xmlns:common="using:SmartPatientCentre.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <x:String x:Key="ChevronGlyph">&#xE26B;</x:String>

        <!-- Data Binding -->
        <CollectionViewSource
        x:Name="PatientList"
        Source="{Binding PatientList}"/>

        <CollectionViewSource
        x:Name="DashboardItems"
        Source="{Binding DashboardItems}"/>
    </Page.Resources>

    <!-- Top AppBar -->
    <Page.TopAppBar>
        <CommandBar>
            <AppBarButton Label="Logout" Icon="Clear" Click="LogoutButtonClick" />
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="My Patients" Icon="ContactInfo" Click="MyPatientsButtonClick" />
                <AppBarButton Label="All Patients" Icon="ViewAll" Click="AllPatientsButtonClick" />
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.TopAppBar>

    <!-- Main Content Grid -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Hub>
            <!-- Title -->
            <Hub.Header>
                <Grid>
                    <TextBlock x:Name="DashboardTitle" Style="{StaticResource HeaderTextBlockStyle}" IsHitTestVisible="false" TextWrapping="NoWrap"/>
                </Grid>
            </Hub.Header>

            <!-- Dashboard Tile -->
            <HubSection>
                <DataTemplate>
                    <GridView
                        ItemsSource="{Binding Source={StaticResource DashboardItems}}"
                        SelectionMode="None"
                        IsItemClickEnabled="True" 
                        ItemClick="Patient_ItemClick">
                        <GridView.ItemTemplate>
                            <DataTemplate>
                                <Grid>

                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <!-- Patient Tile -->
                                    <GridView
                                        Grid.Row="0"
                                        ItemsSource="{Binding Patient}"
                                        ItemTemplate="{StaticResource PatientTile}"
                                        SelectionMode="None"
                                        IsSwipeEnabled="false"
                                        IsHitTestVisible="False"/>

                                    <!-- Result Tiles -->
                                    <GridView
                                        Grid.Row="1"
                                        ItemsSource="{Binding Results}"
                                        ItemTemplate="{StaticResource ResultTile}"
                                        SelectionMode="None"
                                        IsSwipeEnabled="false"
                                        IsHitTestVisible="False" Margin="0,20,0,-10"/>

                                </Grid>
                            </DataTemplate>
                        </GridView.ItemTemplate>
                    </GridView>
                </DataTemplate>
            </HubSection>

        </Hub>
    </Grid>
</Page>
